package three;
import java.util.*;

public class A055 {

    //子集
    List<List<Integer>> ret = new ArrayList<>();
    List<Integer> path = new ArrayList<>();
    public List<List<Integer>> subsets(int[] nums) {
        dfs(nums,0);
        return ret;
    }

    public void dfs(int[] nums,int k) {
        //每个节点都是答案
        ret.add(new ArrayList<>(path));

        for(int i=k;i<nums.length;i++) {
            path.add(nums[i]);
            dfs(nums,i+1);
            //回溯
            path.remove(path.size()-1);
        }
    }
}
